//
//  OADCellConfig.m
//  OASDK_Works
//
//  Created by ChenJie on 3/1/20.
//  Copyright © 2020 Mist. All rights reserved.
//

#import "OADCellConfig.h"

@interface OADCellConfig ()

@end

@implementation OADCellConfig

#pragma mark - Lifecycle methods

- (instancetype)init {
    self = [super init];
    if (self) {
    }
    return self;
}

#pragma mark - Public methods

/*
 * UITableViewDataSource
 */

- (UITableViewCell *)cellForRowWithTableView:(UITableView *)tableView {
    NSLog(@"%s", __PRETTY_FUNCTION__);
    
    NSString *cellIdentifier = NSStringFromClass(self.cellClass);
    UITableViewCell<OADCellProtocol> *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        [tableView registerClass:self.cellClass forCellReuseIdentifier:cellIdentifier];
        cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    }
    cell.viewModel = self.cellViewModel;
    cell.oad_layout = self.cellLayout;
    
    return cell;
}

/*
 * UITableViewDelegate
 */

- (CGFloat)heightForRow {
    
    NSLog(@"%s", __PRETTY_FUNCTION__);
    
    if (self.staticCellHeight) {
        self.cellLayout = [self.cellClass layoutWithViewModel:self.cellViewModel
                                             staticCellHeight:self.staticCellHeight];
        return self.staticCellHeight;
    }
    
    self.cellLayout = [self.cellClass layoutWithViewModel:self.cellViewModel];
    CGFloat cellHeight = [self.cellClass cellHeightLayoutsWithViewModel:self.cellViewModel
                                                                 layout:self.cellLayout];
    
    NSLog(@"cell height: %f", cellHeight);
    
    return cellHeight;
}

#pragma mark - Private methods



#pragma mark - Delegate methods



#pragma mark - Setter



#pragma mark - Getter



#pragma mark - Memory management methods

- (void)dealloc {
}

@end
